package com.lagou.controller;

import com.lagou.entity.TArticle;
import com.lagou.service.TArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Calendar;
import java.util.List;

@Controller
public class LoginController {

    @Autowired
    TArticleService service;

    // 自动跳转到/templates/login.html
    @RequestMapping("/toLoginPage")
    public String toLoginPage(Model model) {
        //模板中添加属性currentYear
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    @RequestMapping("clientBlog")
    public String clientBlog(Model model) {
        List<TArticle> list = service.selectArticleList();

        //模板中添加属性currentYear
        model.addAttribute("articleList",list);
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "/client/index";
    }


}
